<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    let obj = {}
    for (let i = 0; i < 5; i++) {

        i !== 3 && Object.defineProperty(obj, "name" + i, {
            configurable: false,
            enumerable: true, // 默认是false
            value: "value" + i
        })

        i === 3 && Object.defineProperty(obj, "name" + i, {
            configurable: false,
            enumerable: false,
            value: "value" + i
        })
    }

    console.log("obj:", obj)
    console.log("是否有name2这个属性：", obj.hasOwnProperty("name2")) // true、
    console.log("验证name0是否可枚举：", Object.getOwnPropertyDescriptor(obj, "name0").enumerable)
    console.log("验证name3是否可枚举：", Object.getOwnPropertyDescriptor(obj, "name3").enumerable)

    for(item in obj){
        console.log(item)
    }
    console.log(Object.keys(obj))
    console.log(JSON.stringify(obj))
</script>
</body>
</html>